#pragma once
#include "../../Ode.h"

namespace Skill
{
	namespace Ode
	{
		namespace Geometries
		{
			ref class DIndexBuffer;
			ref class DVertexBuffer;

			public ref class DTriMeshData : DIUnmanagedPointer
			{
				INTERNAL_CLASS_DECLARATION_NO_FINALIZE(DTriMeshData,dxTriMeshData);
			public:
				UNMANAGEDPOINTER_DECLARATION();

				!DTriMeshData()
				{
					if(_Free && _This)
						dGeomTriMeshDataDestroy(_This);
					_This = nullptr;
					_Free = false;
					_Disposed = true;
				}
				DTriMeshData(DVertexBuffer^ vertices,DIndexBuffer^ indices);				
				DTriMeshData(DVertexBuffer^ vertices,DIndexBuffer^ indices , DVertexBuffer^ normals);				

				REF_PROP_DECLARATION_GET(DVertexBuffer,Vertices);
				REF_PROP_DECLARATION_GET(DVertexBuffer,Normals);
				REF_PROP_DECLARATION_GET(DIndexBuffer,Indices);

				//enum { TRIMESH_FACE_NORMALS };
				//ODE_API void dGeomTriMeshDataSet(dTriMeshDataID g, int data_id, void* in_data);
				//ODE_API void* dGeomTriMeshDataGet(dTriMeshDataID g, int data_id);				

				///<summary> Preprocess the trimesh data to remove mark unnecessary edges and vertices </summary>
				void Preprocess();

				///<summary> Get and set the internal preprocessed trimesh data buffer, for loading and saving </summary>
				//ODE_API void dGeomTriMeshDataGetBuffer(dTriMeshDataID g, unsigned char** buf, int* bufLen);
				//ODE_API void dGeomTriMeshDataSetBuffer(dTriMeshDataID g, unsigned char* buf);

				void Update();

			};
		}
	}
}